<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <meta name="twitter:site" content="@metroui">
    <meta name="twitter:creator" content="@pimenov_sergey">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="Metro 4 Components Library">
    <meta name="twitter:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta name="twitter:image" content="https://metroui.org.ua/images/m4-logo-social.png">

    <meta property="og:url" content="https://metroui.org.ua/v4/index.html">
    <meta property="og:title" content="Metro 4 Components Library">
    <meta property="og:description" content="Metro 4 is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with responsive grid system, extensive prebuilt components, and powerful plugins  .">
    <meta property="og:type" content="website">
    <meta property="og:image" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:secure_url" content="https://metroui.org.ua/images/m4-logo-social.png">
    <meta property="og:image:type" content="image/png">
    <meta property="og:image:width" content="968">
    <meta property="og:image:height" content="504">

    <meta name="author" content="Sergey Pimenov">
    <meta name="description" content="Progress and activity indicators are visual indications of an app loading content or process executed. The most popular HTML, CSS, and JS library in Metro style.">
    <meta name="keywords" content="HTML, CSS, JS, Metro, CSS3, Javascript, HTML5, UI, Library, Web, Development, Framework">

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="icon" href="favicon.ico" type="image/x-icon">

    <link href="metro/css/metro-all.css?ver=@@b-version" rel="stylesheet">
    <link href="highlight/styles/github.css" rel="stylesheet">
    <link href="docsearch/docsearch.min.css" rel="stylesheet">
    <link href="css/site.css" rel="stylesheet">

    <title>Progress and Activity - Metro 4 :: Popular HTML, CSS and JS library</title>
</head>
<body class="m4-cloak">

<header data-role="html-container" data-insert-mode="replace" data-html-source="header.html"></header>

<div data-role="html-container" data-insert-mode="replace" data-html-source="sidebar-menu.html"></div>

<div class="container-fluid docs-content">

    <div class="row flex-xl-nowrap">

            <div class="d-none d-block-xl cell-xl-2 order-2 border-left bd-light toc-wrapper">
                <h5>Table of contents</h5>
                <hr/>
                <ul class="toc-nav">
                    <li class="toc-entry"><a href="#">Progress &amp; Activity</a></li>
                    <li class="toc-entry"><a href="#_activity_types">Activity indicators</a></li>
                    <li class="toc-entry">
                        <a href="#_activity_types">Activities</a>
                        <ul>
                            <li class="toc-entry"><a href="#_activity_type_ring">Ring</a></li>
                            <li class="toc-entry"><a href="#_activity_type_metro">Metro</a></li>
                            <li class="toc-entry"><a href="#_activity_type_square">Square</a></li>
                            <li class="toc-entry"><a href="#_activity_type_cycle">Cycle</a></li>
                            <li class="toc-entry"><a href="#_activity_type_simple">Simple</a></li>
                            <li class="toc-entry"><a href="#_activity_overlay">Activity overlay</a></li>
                        </ul>
                    </li>
                    <li class="toc-entry">
                        <a href="#_progress_about">Progress indicator</a>
                        <ul>
                            <li class="toc-entry"><a href="#_progress_bar">Bar</a></li>
                            <li class="toc-entry"><a href="#_progress_buffer">Buffer</a></li>
                            <li class="toc-entry"><a href="#_progress_load">Load</a></li>
                            <li class="toc-entry"><a href="#_progress_line">Line</a></li>
                            <li class="toc-entry"><a href="#_progress_customize">Customize</a></li>
                            <li class="toc-entry"><a href="#_progress_events">Events</a></li>
                            <li class="toc-entry"><a href="#_progress_callbacks">Callbacks</a></li>
                            <li class="toc-entry"><a href="#_progress_observe">Observe</a></li>
                            <li class="toc-entry"><a href="#_progress_set_and_get_values">Set and get value</a></li>
                        </ul>
                    </li>
                </ul>

            </div>

            <main class="cell-xl-10 order-1 pr-1-sx pl-1-sx pr-5-md pl-5-md">
                <div class="place-right d-none d-block-lg" style="width: 200px;">
                    <img src="images/logo.png" class="w-100" alt="">
                </div>

                <h1>Progress &amp; Activity</h1>
                <p class="text-leader">
                    Progress and activity indicators are visual indications of an app loading content or process executed.
                </p>

                <!-- ads-html -->

                <h3 id="_activity_types">Activity indicators</h3>
                <p>
                    Metro 4 implements several activity indicators, which you can use easily and simply.
                    To create activity indicator add <code>data-role="activity"</code> attribute to element and define additional options.
                    The activity indicator type define with <code>data-type=*</code> attribute.
                    Currently supports four types for activity indicators:
                        <code>ring</code>,
                        <code>metro</code>,
                        <code>square</code>,
                        <code>cycle</code>.
                </p>
                <p>
                    In addition you can define color subtype for activity indicator with attribute <code>data-style</code> and predefined values: <code>light</code> (default), <code>dark</code> and <code>color</code>.
                </p>

                <h4 id="_activity_type_ring">Ring</h4>

                <div class="example">
                    <div class="row">
                        <div class="cell-md-4 bg-darkGray text-center">
                            <div class="mx-auto" data-role="activity" data-type="ring"></div>
                        </div>
                        <div class="cell-md-4 text-center">
                            <div class="mx-auto" data-role="activity" data-type="ring" data-style="dark"></div>
                        </div>
                        <div class="cell-md-4">
                            <div class="mx-auto" data-role="activity" data-type="ring" data-style="color"></div>
                        </div>
                    </div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="activity" data-type="ring"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="ring" data-style="dark"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="ring" data-style="color"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_activity_type_metro">Metro</h4>

                <div class="example">
                    <div class="row">
                        <div class="cell-md-4 bg-darkGray text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="metro"></div>
                        </div>
                        <div class="cell-md-4 text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="metro" data-style="dark"></div>
                        </div>
                        <div class="cell-md-4 p-2">
                            <div class="mx-auto" data-role="activity" data-type="metro" data-style="color"></div>
                        </div>
                    </div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="activity" data-type="metro"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="metro" data-style="dark"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="metro" data-style="color"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_activity_type_square">Square</h4>

                <div class="example">
                    <div class="row">
                        <div class="cell-md-4 bg-darkGray text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="square"></div>
                        </div>
                        <div class="cell-md-4 text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="square" data-style="dark"></div>
                        </div>
                        <div class="cell-md-4 p-2">
                            <div class="mx-auto" data-role="activity" data-type="square" data-style="color"></div>
                        </div>
                    </div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="activity" data-type="square"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="square" data-style="dark"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="square" data-style="color"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_activity_type_cycle">Cycle</h4>

                <div class="example">
                    <div class="row">
                        <div class="cell-md-4 bg-darkGray text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="cycle"></div>
                        </div>
                        <div class="cell-md-4 text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="cycle" data-style="dark"></div>
                        </div>
                        <div class="cell-md-4 p-2">
                            <div class="mx-auto" data-role="activity" data-type="cycle" data-style="color"></div>
                        </div>
                    </div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="activity" data-type="cycle"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="cycle" data-style="dark"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="cycle" data-style="color"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_activity_type_simple">Simple</h4>

                <div class="example">
                    <div class="row">
                        <div class="cell-md-4 bg-darkGray text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="simple"></div>
                        </div>
                        <div class="cell-md-4 text-center p-2">
                            <div class="mx-auto" data-role="activity" data-type="simple" data-style="dark"></div>
                        </div>
                        <div class="cell-md-4 p-2">
                            <div class="mx-auto" data-role="activity" data-type="simple" data-style="color"></div>
                        </div>
                    </div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="activity" data-type="simple"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="simple" data-style="dark"&gt;&lt;/div&gt;
                    &lt;div data-role="activity" data-type="simple" data-style="color"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_activity_overlay">Activity overlay</h4>
                <p class="text-small">
                    This feature available from 4.1.20
                </p>
                <p>
                    Metro 4 contains object to create <code>activity overlay</code>. This functionality stored in object <code>Metro.activity</code>. Object contains two methods: <code>open({...})</code> and <code>close(activity)</code>.
                </p>
                <p>Options:</p>
                <ul>
                    <li>type - string, valid activity type</li>
                    <li>style - string, valid activity style</li>
                    <li>autoHide - integer, milliseconds</li>
                    <li>overlayClickClose - boolean, true or false</li>
                    <li>overlayColor - string, hex value, ex: <code>#ffffff</code></li>
                    <li>overlayAlpha - float, from 0 to 1</li>
                    <li>text - additional text. <span class="text-small no-wrap fg-red">New in 4.2.0</span></li>
                </ul>
                <div class="example">
                    <button class="button" onclick="
                        Metro.activity.open({autoHide: 3000})
                    ">Open</button>

                    <button class="button" onclick="
                        Metro.activity.open({
                            type: 'metro',
                            overlayClickClose: true
                        })
                    ">Open</button>

                    <button class="button" onclick="
                        var activity = Metro.activity.open({
                            type: 'square',
                            overlayColor: '#fff',
                            overlayAlpha: 1
                        });
                        setTimeout(function(){
                            Metro.activity.close(activity);
                        }, 5000)
                    ">Open</button>

                    <button class="button" onclick="
                        Metro.activity.open({
                            type: 'square',
                            overlayColor: '#fff',
                            overlayAlpha: 1,
                            text: '<div class=\'mt-2 text-small\'>Please, wait...</div>',
                            overlayClickClose: true
                        });
                    ">Open</button>
                </div>
                <pre><code>
                    &lt;button class="button" onclick="
                        Metro.activity.open({autoHide: 3000})
                    "&gt;Open&lt;/button&gt;

                    &lt;button class="button" onclick="
                        Metro.activity.open({
                            type: 'metro',
                            overlayClickClose: true
                        })
                    "&gt;Open&lt;/button&gt;

                    &lt;button class="button" onclick="
                        var activity = Metro.activity.open({
                            type: 'square',
                            overlayColor: '#fff',
                            overlayAlpha: 1
                        });
                        setTimeout(function(){
                            Metro.activity.close(activity);
                        }, 5000)
                    "&gt;Open&lt;/button&gt;

                    &lt;button class="button" onclick="
                        Metro.activity.open({
                            type: 'square',
                            overlayColor: '#fff',
                            overlayAlpha: 1,
                            text: '&lt;div class=\'mt-2 text-small\'&gt;Please, wait...&lt;/div&gt;',
                            overlayClickClose: true
                        });
                    "&gt;Open&lt;/button&gt;
                </code></pre>

                <!-- ads-html -->

                <h3 id="_progress_about">Progress indicator</h3>
                <p>
                    Metro 4 implements four types of progress indicator.
                    To create progress indicator add <code>data-role="progress"</code> attribute to element and define additional options.
                    The progress indicator type you can define with <code>data-type=*</code> attribute. To set <code>value</code> and <code>buffer</code> add attributes <code>data-value</code> or/and <code>data-buffer</code>.
                </p>

                <h4 id="_progress_bar">Progress bar</h4>
                <div class="example">
                    <div data-role="progress" data-value="35"></div>
                    <div class="mt-1" data-role="progress" data-value="35" data-small="true"></div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="progress" data-value="35"&gt;&lt;/div&gt;

                    &lt;div data-role="progress" data-value="35" data-small="true"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_progress_buffer">Progress bar with buffer</h4>
                <div class="example">
                    <div data-role="progress" data-type="buffer" data-value="35" data-buffer="60"></div>
                    <div class="mt-1" data-role="progress" data-type="buffer" data-value="35" data-buffer="60" data-small="true"></div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="progress" data-type="buffer"
                        data-value="35" data-buffer="60"&gt;&lt;/div&gt;

                    &lt;div data-role="progress" data-type="buffer"
                        data-value="35" data-buffer="60" data-small="true"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_progress_load">Progress bar with buffer and load indicator</h4>
                <div class="example">
                    <div data-role="progress" data-type="load" data-value="35" data-buffer="75"></div>
                    <div class="mt-1" data-role="progress" data-type="load" data-value="35" data-buffer="75" data-small="true"></div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="progress" data-type="load"
                        data-value="35" data-buffer="75"&gt;&lt;/div&gt;

                    &lt;div data-role="progress" data-type="load"
                        data-value="35" data-buffer="75" data-small="true"&gt;&lt;/div&gt;
                </code></pre>

                <h4 id="_progress_line">Progress line</h4>
                <div class="example">
                    <div data-role="progress" data-type="line"></div>
                    <div class="mt-1" data-role="progress" data-type="line" data-small="true"></div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="progress" data-type="line"&gt;&lt;/div&gt;

                    &lt;div data-role="progress" data-type="line" data-small="true"&gt;&lt;/div&gt;
                </code></pre>

                <h3 id="_progress_customize">Customize</h3>
                <p>
                    To set your own custom color use <code>data-cls-back</code>, <code>data-cls-bar</code> and <code>data-cls-buffer</code> attributes.
                </p>
                <div class="example">
                    <div data-role="progress"
                         data-type="buffer"
                         data-cls-back="bg-yellow"
                         data-cls-bar="bg-blue"
                         data-cls-buffer="bg-pink"
                         data-value="25" data-buffer="65"></div>
                </div>
                <pre><code class="html">
                    &lt;div data-role="progress"
                         data-type="buffer"
                         data-cls-back="bg-yellow"
                         data-cls-bar="bg-blue"
                         data-cls-buffer="bg-pink"
                         data-value="25" data-buffer="65"&gt;&lt;/div&gt;
                </code></pre>

                <h3 id="_progress_events">Events</h3>
                <p>
                    When the <code>value</code> or <code>buffer</code> changes in the <code>progress</code>, a <code>change</code> or/and <code>buffer</code> events is fired.
                    You can use this events to observe progress value and buffer.
                </p>
                <pre><code class="javascript">
                    $("#progress").on("valuechange", function(val){
                        console.log(val);
                    });

                    $("#progress").on("bufferchange", function(val){
                        console.log(val);
                    });
                </code></pre>

                <h3 id="_progress_callbacks">Callbacks</h3>
                <p>
                    Progress indicator implements several <code>callbacks</code> to respond to a change in the status of the indicator:
                </p>
                <table class="table cell-border table-border options-table">
                    <thead>
                    <tr>
                        <td>Function</td>
                        <td>Data-*</td>
                        <td>Desc</td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <td>onValueChange(val, el)</td>
                        <td>data-on-value-change</td>
                        <td>Fired when value changes</td>
                    </tr>
                    <tr>
                        <td>onBufferChange(val, el)</td>
                        <td>data-on-buffer-change</td>
                        <td>Fired when buffer changes</td>
                    </tr>
                    <tr>
                        <td>onComplete(val, el)</td>
                        <td>data-on-complete</td>
                        <td>Fired when value is 100%</td>
                    </tr>
                    <tr>
                        <td>onBuffered(val, el)</td>
                        <td>data-on-buffered</td>
                        <td>Fired when buffer is 100%</td>
                    </tr>
                    <tr>
                        <td>onProgressCreate(el)</td>
                        <td>data-on-progress-create</td>
                        <td>Fired when element was created</td>
                    </tr>
                    </tbody>
                </table>
                <pre><code class="html">
                    &lt;div data-role="progress" data-type="load"
                        data-value="35" data-buffer="75"
                        data-on-complete="alert('Complete!!!')"
                        data-on-value-change="console.log(arguments)"
                        data-on-buffer-change="console.log(arguments)"&gt;
                    &lt;/div&gt;
                </code></pre>

                <h3 id="_progress_observe">Observe</h3>
                <p>
                    If you change <code>data-value</code> or <code>data-buffer</code> attributes at runtime, your <code>progress</code> will be updated.
                </p>
                <div class="example">
                    <div id="progress-observe" data-role="progress" data-type="buffer"></div>

                    <div class="mt-2 d-flex">
                        <label style="width: 100px" for="progress-observe-value">Value</label>
                        <input id="progress-observe-value" class="w-100" data-role="slider">
                    </div>
                    <div class="mt-2 d-flex">
                        <label style="width: 100px" for="progress-observe-buffer">Buffer</label>
                        <input id="progress-observe-buffer" class="w-100" data-role="slider">
                    </div>
                </div>
                <pre><code class="html javascript">
                    &lt;div id="progress-observe"
                        data-role="progress"
                        data-type="buffer" class="mb-4"&gt;&lt;/div&gt;

                    &lt;div&gt;
                        &lt;input id="progress-observe-value"
                            class="w-100" type="range"
                            min="0" max="100" value="0"&gt;

                        &lt;input id="progress-observe-buffer"
                            class="w-100"  type="range"
                            min="0" max="100" value="0"&gt;
                    &lt;/div&gt;

                    &lt;script&gt;
                        $(function(){
                            $("#progress-observe-value").on("input change", function(){
                                $("#progress-observe").attr('data-value', this.value);
                            });
                            $("#progress-observe-buffer").on("input change", function(){
                                $("#progress-observe").attr('data-buffer', this.value);
                            });
                        })
                    &lt;/script&gt;
                </code></pre>

                <h3 id="_progress_set_and_get_values">Set and get value</h3>
                <p>
                    Component <code>progress</code> provides method to get and set value for progress.
                    To <code>set</code> or <code>get</code> value use method <code>val()</code>.
                    Also you can <code>set</code> and <code>get</code> values for <code>buffer</code> with method <code>buff()</code>.
                </p>
                <div class="example">
                    <div id="progress_methods" data-role="progress" data-type="buffer"></div>
                    <div class="mt-2 d-flex">
                        <label for="progress_methods_input_val" style="width: 100px">Value</label>
                        <input type="number" min="0" max="100" value="0" id="progress_methods_input_val">
                        <button class="button primary" onclick="alert($('#progress_methods').data('progress').val())">Get value</button>
                    </div>
                    <div class="mt-2 d-flex">
                        <label for="progress_methods_input_buff" style="width: 100px">Buffer</label>
                        <input type="number" min="0" max="100" value="0" id="progress_methods_input_buff">
                        <button class="button secondary" onclick="alert($('#progress_methods').data('progress').buff())">Get value</button>
                    </div>
                </div>
                <pre><code>
                    var progress = $("#element").data("progress");
                    var progress_value;
                    var buffer_value;

                    // set value
                    progress.val(35);
                    progress.buff(65);

                    // get value
                    progress_value = progress.val();
                    buffer_value = progress.buff();
                </code></pre>
            </main>
        </div>

    </div>

    <script src="docsearch/docsearch.min.js"></script>


    <script src="metro/js/metro.js?ver=@@b-version"></script>
    <script src="highlight/highlight.pack.js"></script>
    <script src="js/clipboard.min.js"></script>
    <script src="js/site.js"></script>

    <script>
        $(function(){
            $("#progress-observe-value").on("input change", function(){
                $("#progress-observe").attr('data-value', this.value);
            });

            $("#progress-observe-buffer").on("input change", function(){
                $("#progress-observe").attr('data-buffer', this.value);
            });

            $("#progress_methods_input_val").on("propertychange change keyup input paste", function(){
                $("#progress_methods").data("progress").val(this.value);
            });
            $("#progress_methods_input_buff").on("propertychange change keyup input paste", function(){
                $("#progress_methods").data("progress").buff(this.value);
            });
        })
    </script>

    <!-- ads-script -->
    <!-- ga-script -->
    <!-- hit-ua -->
</body>
</html>